package JDBC;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Scanner;

import static JDBC.InputUtil.*;
import static com.sun.corba.se.impl.util.Utility.printStackTrace;

public class LoginDemo {
    public static void main(String[] args) {
        userinfo userinfo = InputUtil.getInputObject(new userinfo(),"欢迎登录","登录");
        try ( Connection con = DBUtil.getConnection()){
                Statement sta = con.createStatement();
                String sql = "SELECT username,password " +
                        "FROM userinfo " +
                        "WHERE username='"+userinfo.getUsername()+"' AND password='"+userinfo.getPassword()+"'";
                ResultSet rs = sta.executeQuery(sql);
                if(rs.next()){
                        System.out.println("登陆成功");
                }else{
                        System.out.println("登陆失败");
                }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
